<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <link rel="stylesheet" href="./css/reset.css">
    <link rel="stylesheet" href="./css/layui/css/layui.css">
    <link rel="stylesheet" href="./css/01-Amy-market.css">
    <title>koubei</title>
</head>

<body>
    <div id="wrap">
        <div class="heardFont">
            <span>口碑统计</span>
        </div>
        <div id="content">
            <div id="header">
                <span class="active">登记量和报名统计</span>
                <span>退单系统</span>
                <span>咨询系统</span>
            </div>
            <div id="middle">
                <span>日期选择：</span>
                <em class="active2">本月</em>
                <em>上月</em>
                <div>
                    <span>选择日期</span>
                    <ul>
                        <input id="day" placeholder="开始日期">
                        -- <input id="day2" placeholder="截止日期">
                    </ul>
                </div>
            </div>
            <table>
                <tr>
                <th>地区</th>
                <th>Java</th>
                <th>Java精英班</th>
                <th>Web大前端</th>
                <th>UI视觉设计</th>
                <th>大数据</th>
                <th>Python课程</th>
                <th>Unity3D</th>
            </tr>
            </table>
        </div>
</body>

<script src="./js/jquery-3.4.1.js"></script>
<script src="./css/layui/layui.js"></script>
<script src="./js/01-Amy-market.js"></script>
<script src="./js/url.js"></script>

<script>
    $(function(){
        $.ajax({
        type: "post",
        url: SetUrl.dataUrl.koubei,
        dataType: "json",
        data: {
            method: 'cMonth'
        },
        success: function (data) {
            console.log(data)
            if (data.code == 200) {
                console.log(data.result)
                var a = data.result;
                $('th').parent().siblings().remove();
                for (var k in a) {
                    $('<tr><td>'+ k +'</td><td>'+ (a[k].Java || 0) +'</td><td>'+ (a[k].Java大数据 || 0) +'</td><td>'+ (a[k].Html || 0) +'</td><td>'+ (a[k].UI || 0) +'</td><td>'+ (a[k].bigDataCount || 0) +'</td><td>'+ (a[k].Python || 0) +'</td><td>'+ (a[k].UI3D || 0) +'</td></tr>').appendTo('table')
                    }
            }
        },
        error: function (xhr, error) {
            console.log(error)
        }
    })
    })
    
    // 本月
    $('#precedMonth').click(function () {
        $.ajax({
        type: "post",
        url: SetUrl.dataUrl.koubei,
        dataType: "json",
        data: {
            method: 'cMonth'
        },
        success: function (data) {
            console.log(data)
            if (data.code == 200) {
                console.log(data.result)
                var a = data.result;
                $('th').parent().siblings().remove();
                for (var k in a) {
                    $('<tr><td>'+ k +'</td><td>'+ (a[k].Java || 0) +'</td><td>'+ (a[k].Java大数据 || 0) +'</td><td>'+ (a[k].Html || 0) +'</td><td>'+ (a[k].UI || 0) +'</td><td>'+ (a[k].bigDataCount || 0) +'</td><td>'+ (a[k].Python || 0) +'</td><td>'+ (a[k].UI3D || 0) +'</td></tr>').appendTo('table')
                    }
            }
        },
        error: function (xhr, error) {
            console.log(error)
        }
    })
    })
    // 上月
    $('#thisMonth').click(function () {
        $.ajax({
        type: "post",
        url: SetUrl.dataUrl.koubei,
        dataType: "json",
        data: {
            method: 'cMonth'
        },
        success: function (data) {
            console.log(data)
            if (data.code == 200) {
                console.log(data.result)
                var a = data.result;
                $('th').parent().siblings().remove();
                for (var k in a) {
                    $('<tr><td>'+ k +'</td><td>'+ (a[k].Java || 0) +'</td><td>'+ (a[k].Java大数据 || 0) +'</td><td>'+ (a[k].Html || 0) +'</td><td>'+ (a[k].UI || 0) +'</td><td>'+ (a[k].bigDataCount || 0) +'</td><td>'+ (a[k].Python || 0) +'</td><td>'+ (a[k].UI3D || 0) +'</td></tr>').appendTo('table')
                    }
            }
        },
        error: function (xhr, error) {
            console.log(error)
        }
    })
    })
    $('#day2').click(function () {
        $('#layui-laydate2 td').unbind();
        $('#layui-laydate2 td').click(function () {
            // alert(1)
            console.log($('#day').val())
            console.log($('#day2').val())
            if ($('#day2').val() >= $('#day').val()) {
                $.ajax({
        type: "post",
        url: SetUrl.dataUrl.koubei,
        dataType: "json",
        data: {
            method: 'cMonth'
        },
        success: function (data) {
            console.log(data)
            if (data.code == 200) {
                console.log(data.result)
                var a = data.result;
                $('th').parent().siblings().remove();
                for (var k in a) {
                    $('<tr><td>'+ k +'</td><td>'+ (a[k].Java || 0) +'</td><td>'+ (a[k].Java大数据 || 0) +'</td><td>'+ (a[k].Html || 0) +'</td><td>'+ (a[k].UI || 0) +'</td><td>'+ (a[k].bigDataCount || 0) +'</td><td>'+ (a[k].Python || 0) +'</td><td>'+ (a[k].UI3D || 0) +'</td></tr>').appendTo('table')
                    }
            }
        },
        error: function (xhr, error) {
            console.log(error)
        }
    })
            } else if ($('#day2').val() < $('#day').val()) {
                alert('时间错误')
            }
        })
    })
    $('#day').click(function () {
        $('#layui-laydate1 td').unbind();
        $('#layui-laydate1 td').click(function () {
            // alert(1)
            console.log($('#day').val())
            console.log($('#day2').val())
            if ($('#day2').val() >= $('#day').val()) {
                $.ajax({
        type: "post",
        url: SetUrl.dataUrl.koubei,
        dataType: "json",
        data: {
            method: 'cMonth'
        },
        success: function (data) {
            console.log(data)
            if (data.code == 200) {
                console.log(data.result)
                var a = data.result;
                $('th').parent().siblings().remove();
                for (var k in a) {
                    $('<tr><td>'+ k +'</td><td>'+ (a[k].Java || 0) +'</td><td>'+ (a[k].Java大数据 || 0) +'</td><td>'+ (a[k].Html || 0) +'</td><td>'+ (a[k].UI || 0) +'</td><td>'+ (a[k].bigDataCount || 0) +'</td><td>'+ (a[k].Python || 0) +'</td><td>'+ (a[k].UI3D || 0) +'</td></tr>').appendTo('table')
                    }
            }
        },
        error: function (xhr, error) {
            console.log(error)
        }
    })
            } else if ($('#day2').val() < $('#day').val()) {
                alert('时间错误')
            }
        })
    })
</script>
</html>